<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>location地址栏对象</title>
    <style>
        p{
            text-align: center;
        }
        span{
            color: red;
        }
    </style>
</head>
<body>
    <p>
        注册成功！<span id="time">5</span>秒后跳转到首页...
    </p>
</body>
<script>
    //定义方法。改变秒数，跳转页面
    let num = 5;
    function showtime() {
        num--;

        if (num <= 0) {
            location.href = "show.html";
        }

        let span = document.getElementById("time");
        span.innerText = num;
    }

    //设置循环定时器，每秒钟执行showtime方法
    setInterval("showtime()",1000);
</script>
</html>